package com.bsj.power.pls.initialize;

import com.bsj.power.common.def.entity.Panel;
import com.bsj.power.common.mapper.PanelMapper;
import com.bsj.power.pls.cache.PanelCache;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description PanelInitialize
 * @time 2024/10/21 19:35
 */
@Component
public class PanelInitialize {

    @Resource
    private PanelMapper panelMapper;

    /**
     * 加载所有绑定关系
     *
     * @return void
     * @author ljx
     * @time 2024/10/21 19:40
     */
    public void initialize() {
        List<Panel> panels = panelMapper.selectList(null);
        for (Panel panel : panels) {
            String srcIndex = panel.getSrcIndex();
            PanelCache.addSrcIndex(srcIndex);
            PanelCache.putRelation(srcIndex, panel.getDeviceId());
        }
    }

}
